window.onload = function(){
			var d1 = new add();
            d1.init()
        var oDiv=document.getElementById('div');
		
		var x=0;
		var y=0;
		oDiv.onmousedown=function(ev){
			var oTip=document.createElement('p');
			oTip.className='tip';
			oTip.style.left=x+'px';
			oTip.style.top=y+'px';	
			document.body.appendChild(oTip);
			var ev=ev||event;
			var disX=ev.clientX-oDiv.offsetLeft;
			var disY=ev.clientY-oDiv.offsetTop;
			document.onmousemove=function(ev){
				var ev=ev||event;
				x=ev.clientX-disX;
				y=ev.clientY-disY;
				oTip.style.left=x+'px';
				oTip.style.top=y+'px';	
			};
			document.onmouseup=function(){
				
				oDiv.style.left=x+'px';
				oDiv.style.top=y+'px';
				document.body.removeChild(oTip);
				document.onmouseup=null;
				document.onmousemove=null;
			};
			return false;
		};
			
            
		}
		function add(){
			this.oDiv = document.getElementById("box");
			this.divX = 0;
			this.divY = 0;
			
		}
		add.prototype.init = function(){
			var Tthis = this
			this.oDiv.onmousedown = function(ev){
				Tthis.fnDown(ev);
			}
		}
		add.prototype.fnDown = function(ev){
			var ev = ev || event;
			this.divX = ev.clientX - this.oDiv.offsetLeft;
			this.divY = ev.clientY - this.oDiv.offsetTop;
			
			var Tthis = this
			document.onmousemove = function (ev) {
                Tthis.fnMove(ev);
            };
            document.onmouseup = this.fnUp;
            return false;
		}
		 add.prototype.fnUp = function () {
            document.onmousemove = null;
            document.onmouseup = null;
        };

        add.prototype.fnMove = function (ev) {
            var ev = ev || event;
            this.oDiv.style.left = ev.clientX - this.divX + "px";
            this.oDiv.style.top = ev.clientY - this.divY + "px";
        }